// 基于template/src/widgets/{{appEntities}}/{{ctrls@GRID}}-grid/{{spinalCase ctrl.codeName}}-grid-model.ts.hbs生成
import { IGridModel, IParam, isEmpty, VerifyUtil } from '@/core';

function getModel(): IGridModel {
    return {
        cssName: "",
        aggMode: 'ALL',
        aggDeCodeName: 'IBIZBOOK',
        aggDataSet: '',
        caption: '',
        controlType: 'GRID',
        codeName: 'Main5',
        singleSelect: false,
        columns: getGridColumns(),
        dataItems: getGridDataItems(),
        dataExport: getDataExport(),
        enableRowEdit: false,
        entityCodeName: 'IBIZBOOK',
        entityLogicName: '图书',
        createDefaultItems: getCreateDefaultItems(),
        updateDefaultItems: getUpdateDefaultItems(),
        name: 'grid',
        noSort: false,
        rules: {
            //	静态值规则
            staticRules: {
            },
            //	编辑项值规则
            editRules: [
            ]
        },
        showHeader: true,
        sortDir: '',
        sortField: '',
        limit: 20,
        dataImport: {
            codeName: 'DataImport',
            ignoreError: false,
            importItems: [
                {
                    name: 'author',
                    caption: App.ts('DEF.LNAME.AUTHOR', '图书作者'),
                    fieldCodeName: 'author'
                },
                {
                    name: 'booknumber',
                    caption: App.ts('DEF.LNAME.BOOKNUMBER', '图书数量'),
                    fieldCodeName: 'booknumber'
                },
                {
                    name: 'borrowway',
                    caption: App.ts('DEF.LNAME.BORROWWAY', '借阅方式'),
                    codeListTag: 'Sample__CodeList25',
                    fieldCodeName: 'borrowway'
                },
                {
                    name: 'ibizbookid',
                    caption: App.ts('DEF.LNAME.IBIZBOOKID', '图书标识'),
                    fieldCodeName: 'ibizbookid'
                },
                {
                    name: 'ibizbookname',
                    caption: App.ts('DEF.LNAME.IBIZBOOKNAME', '图书名称'),
                    fieldCodeName: 'ibizbookname'
                },
                {
                    name: 'press',
                    caption: App.ts('DEF.LNAME.PRESS', '图书出版社'),
                    fieldCodeName: 'press'
                },
                {
                    name: 'price',
                    caption: App.ts('DEF.LNAME.PRICE', '图书价格'),
                    fieldCodeName: 'price'
                },
                {
                    name: 'sailstate',
                    caption: App.ts('DEF.LNAME.SAILSTATE', '图书销售状态'),
                    codeListTag: 'Sample__BookSailState',
                    fieldCodeName: 'sailstate'
                },
                {
                    name: 'subtext',
                    caption: App.ts('DEF.LNAME.SUBTEXT', '图书描述'),
                    fieldCodeName: 'subtext'
                },
                {
                    name: 'tag',
                    caption: App.ts('DEF.LNAME.TAG', '标签'),
                    fieldCodeName: 'tag'
                },
                {
                    name: 'type',
                    caption: App.ts('DEF.LNAME.TYPE', '图书类型'),
                    codeListTag: 'Sample__BookType',
                    fieldCodeName: 'type'
                }
            ]
        },
        paging: {
            defaultPageSize: 20,
        }
    }
}
//  获取所有表格列模型
function getGridColumns(): IParam[] {
    return [
        {
            align: 'left',
            codeName: 'type',
            caption: '图书类型',
            captionLanResTag: 'DEF.LNAME.TYPE',
            cellCssName: '',
            columnType: 'DEFGRIDCOLUMN',
            codeListTag: 'Sample__BookType',
            dataItemName: 'type',
            dataIndex: 'type',
            sorter: true,
            enableRowEdit: false,
            enableSort: true,
            excelCaption: '图书类型',
            headerCssName: '',
            show: true,
            hiddenDataItem: false,
            name: 'type',
            width: 280,
            resizable: true,
            stdDataType: 25,
            valueFormat: '',
        },
        {
            align: 'left',
            codeName: 'author',
            caption: '图书作者',
            captionLanResTag: 'DEF.LNAME.AUTHOR',
            cellCssName: '',
            columnType: 'DEFGRIDCOLUMN',
            dataItemName: 'author',
            dataIndex: 'author',
            sorter: true,
            enableRowEdit: false,
            enableSort: true,
            excelCaption: '图书作者',
            headerCssName: '',
            show: true,
            hiddenDataItem: false,
            name: 'author',
            width: 280,
            resizable: true,
            stdDataType: 25,
            valueFormat: '',
        },
        {
            align: 'left',
            codeName: 'ibizbookname',
            caption: '图书名称',
            captionLanResTag: 'DEF.LNAME.IBIZBOOKNAME',
            cellCssName: '',
            columnType: 'DEFGRIDCOLUMN',
            dataItemName: 'ibizbookname',
            dataIndex: 'ibizbookname',
            sorter: true,
            enableRowEdit: false,
            enableSort: true,
            excelCaption: '图书名称',
            headerCssName: '',
            show: true,
            hiddenDataItem: false,
            name: 'ibizbookname',
            minWidth: 100,
            width: 150,
            resizable: true,
            stdDataType: 25,
            valueFormat: '',
        },
        {
            align: 'left',
            aggMode: 'SUM',
            aggField: 'booknumber',
            aggValueFormat: ``,
            codeName: 'booknumber',
            caption: '图书数量',
            captionLanResTag: 'DEF.LNAME.BOOKNUMBER',
            cellCssName: '',
            columnType: 'DEFGRIDCOLUMN',
            dataItemName: 'booknumber',
            dataIndex: 'booknumber',
            sorter: true,
            enableRowEdit: false,
            enableSort: true,
            excelCaption: '图书数量',
            headerCssName: '',
            show: true,
            hiddenDataItem: false,
            name: 'booknumber',
            width: 280,
            resizable: true,
            stdDataType: 9,
            valueFormat: '',
        },
        {
            align: 'left',
            codeName: 'press',
            caption: '图书出版社',
            captionLanResTag: 'DEF.LNAME.PRESS',
            cellCssName: '',
            columnType: 'DEFGRIDCOLUMN',
            dataItemName: 'press',
            dataIndex: 'press',
            sorter: true,
            enableRowEdit: false,
            enableSort: true,
            excelCaption: '图书出版社',
            headerCssName: '',
            show: true,
            hiddenDataItem: false,
            name: 'press',
            width: 280,
            resizable: true,
            stdDataType: 25,
            valueFormat: '',
        },
        {
            caption: "",
            columnType: "EMPTYCOLUMN",
            dataIndex: "autowidthcolumn",
            align: "center",
            resizable: true,
            width: 0,
            ellipsis: true,
            aggMode: "NONE"
        },
    ];
}

//  获取所有表格数据项
function getGridDataItems() {
    return [
        {
            name: 'type',
            codeName: '',
            fieldCodeName: 'type',
            fieldName: 'type',
            valueFormat: '',
            dataType: '25'
        },
        {
            name: 'author',
            codeName: '',
            fieldCodeName: 'author',
            fieldName: 'author',
            valueFormat: '',
            dataType: '25'
        },
        {
            name: 'ibizbookname',
            codeName: '',
            fieldCodeName: 'ibizbookname',
            fieldName: 'ibizbookname',
            valueFormat: '',
            dataType: '25'
        },
        {
            name: 'booknumber',
            codeName: '',
            fieldCodeName: 'booknumber',
            fieldName: 'booknumber',
            valueFormat: '',
            dataType: '9'
        },
        {
            name: 'press',
            codeName: '',
            fieldCodeName: 'press',
            fieldName: 'press',
            valueFormat: '',
            dataType: '25'
        },
        {
            name: 'ibizbookid',
            codeName: '',
            fieldCodeName: 'ibizbookid',
            fieldName: 'ibizbookid',
            valueFormat: '',
            dataType: '25'
        },
        {
            name: 'srfkey',
            codeName: '',
            fieldCodeName: 'ibizbookid',
            fieldName: 'ibizbookid',
            valueFormat: '',
            dataType: '25'
        },
        {
            name: 'srfdataaccaction',
            codeName: '',
            fieldCodeName: 'ibizbookid',
            fieldName: 'ibizbookid',
            valueFormat: '',
            dataType: '25'
        },
        {
            name: 'srfmajortext',
            codeName: '',
            fieldCodeName: 'ibizbookname',
            fieldName: 'ibizbookname',
            valueFormat: '',
            dataType: '25'
        },
        {
            name: 'srfmstag',
            codeName: '',
        },
    ];
}

function getDataExport() {
    return {
        default: true,
        codeName: 'default',
        enableFront: true,
        fileName: '图书',
        exportItems: [
            {
                name: 'type',
                label: '图书类型',
                labelLanResTag: 'DEF.LNAME.TYPE',
                dataType: 25,
                codeListTag: 'Sample__BookType',
                show: true
            },
            {
                name: 'author',
                label: '图书作者',
                labelLanResTag: 'DEF.LNAME.AUTHOR',
                dataType: 25,
                show: true
            },
            {
                name: 'ibizbookname',
                label: '图书名称',
                labelLanResTag: 'DEF.LNAME.IBIZBOOKNAME',
                dataType: 25,
                show: true
            },
            {
                name: 'booknumber',
                label: '图书数量',
                labelLanResTag: 'DEF.LNAME.BOOKNUMBER',
                dataType: 9,
                show: true
            },
            {
                name: 'press',
                label: '图书出版社',
                labelLanResTag: 'DEF.LNAME.PRESS',
                dataType: 25,
                show: true
            }
        ]
    }
}

function getCreateDefaultItems() {
    return [
    ]
}

function getUpdateDefaultItems() {
    return [
    ];
}

export const model = getModel();